// pages/wellcome/wellcome.js
import api from '../../config/settings'
Page({
    data: {
        second:3,
        img:"/images/bg/splash.png"
    },
    doJump(){
        wx.switchTab({
          url: '/pages/index/index',
        })
    },
    onLoad(options) {
        wx.request({
          url: api.welcome,
          method:'GET',
          success:(res)=>{
              if (res.data.code == 100) {
                  this.setData({
                      img:res.data.result
                  })
              } else {
                  wx.showToast({
                    title: '网络请求异常',
                  })
              }
          }
        })
        var jumpTimer = setInterval(()=>{
            if (this.data.second <= 0) {
                clearInterval(jumpTimer)
                this.doJump()
            } else {
                this.setData({
                    second:this.data.second-1
                })
            }
        }, 1000)
    }
})